import numpy as np
# arr1 = np.arange(0,4,1)
# print(arr1)
#
# arr2 = np.arange(1,10,2)
# print(arr2)
#
# arr3 = np.arange(0,1,0.2)
# print(arr3)
#
# arr4 = np.arange(5,0,-1)
# print(arr4)
#
# arr5 = np.linspace(5,12,num=5,endpoint=False,retstep=True)
# print(arr5)

score = np.arange(0,160,10,dtype='int')
print('成绩数组score: \n',score)

height = np.linspace(1.5,2.5,11,retstep=True)
print('身高等差数组: \n',height)

wheat = np.logspace(0,63,64,base=2,dtype='uint64')
print('棋盘麦粒等比数列: \n',wheat)


import numpy as np
# arr1 = np.array([[10,20,30],[40,50,60]])
# print('2x3的数组arr1: \n',arr1)
# arr2 = np.array([[1,2,2],[2,2,3]])
# print('2x3的数组arr2: \n',arr2)
# print('加法: \n',arr1 + arr2)
# print('减法: \n', arr1 - arr2)
# print('乘法: \n',arr1 * arr2)
# print('除法: \n',arr1/arr2)
# print('幂运算: \n', arr1**arr2)


# arr1 = np.array([[10,20,30],[40,50,60]])
# arr2 = np.array([1,2,3])
# print('1和2相加: \n',arr1 + arr2)
# arr3 = np.array([[1],[2]])
# print('1和3相加: \n',arr1 + arr3)
# arr4 = np.array(5)
# print('1和4相加: \n',arr1 + arr4)



# arr = np.random.randint(1,100,size=(3,4))
# print('3x4的原数组: \n',arr)
# print('转置后: \n',arr.T)
# print('变形后: \n',arr.reshape(2,6))



arr1 = np.random.randint(1,10,size=(3,3))
print('随机生成的二维数组arr1: \n',arr1)
arr2 = np.random.randint(1,10,size=3)
print('随机生成的整数数组arr2: \n',arr2)
arr3 = np.random.rand(3,3)*10
print('随机生成的小数数组arr3: \n',arr3)
print('1和2相加: \n',arr1 + arr2)
print('1和3相乘: \n',arr1 * arr3)
print('以1为底，2为指数的幂: \n',np.power(arr1, arr2, dtype='int64'))
print('1的倒数: \n',np.reciprocal(arr1, dtype='float'))
print('3的四舍五入，小数点后一位: \n',np.around(arr3,decimals=1))
print('1的余弦值: \n',np.cos(arr1 * np.pi / 180))

import numpy as np
arr = np.array([[110,120,90,80],[89,95,77,92],[60,79,96,80]])
print('3x4的数组: \n',arr)
print('第3行和第1列的元素: \n',arr[[2,0]])
print('第3行第2列和第1行第1列的元素',arr[[2,0],[1,0]])
print('大于80且小于100的所有元素:',arr[(arr>80)&(arr<100)])
print('小于等于80的所有元素:',arr[arr<=80])

import numpy as np
arr = np.array([[11,13,18],[45,46,78],[15,87,33]],dtype=('int32'))
print(arr)
print(arr.ndim)
print('第2行，第3列的元素',arr[[1,2]])
print('第2行、列步长为2的元素',arr[1,::2])
print('第1~2行、第2~3列的元素: \n',arr[0:2,1:3])
print('第1行第2列、第2行第3列的元素',arr[[0,1],[1,2]])
print('大于30小于80的元素',arr[(arr>30)&(arr<80)])
arr1=np.linspace(0,50,num=6,retstep=True)
print('显示公差',arr1)
arr2=np.logspace(0,8,num=6,)